package club.haomoon.core.util;

import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * -------------------------
 * @Description: 系统配置工具类
 * @Author: Wangjianwei
 * @Date: 2025/02/12 13:59
 * -------------------------
 */
@Component
public class PropertyUtil implements EnvironmentAware {

        private static Environment env;

        /**
         * 设置环境变量
         * @param environment 环境变量
         */
        @Override
        public void setEnvironment(Environment environment) {
            PropertyUtil.env = environment;
        }

        /**
         * 根据Key获取值
         * @param key 键
         * @return String
         */
        public static String get(String key) {
            return env.getProperty(key);
        }
}
